﻿using FPSO.Models.Constant;
using FPSO.Models.Domain;
using FPSO.Models.ViewModel.Controls;
using FPSO.Services;
using FPSO.Services.Impl;
using Opc.Ua;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FPSO.HMI.Controls
{
    /// <summary>
    /// UCShipInfo.xaml 的交互逻辑
    /// </summary>
    public partial class UCShipInfo : UserControl
    {
        private UCShipInfoViewModel viewModel;
        //private IDataBindingService bindingService;
        //private SafeLoadAlgorithmService safeLoadService;
        //private ITankLevelService tankLevelService;

        public UCShipInfo()
        {
            InitializeComponent();

            viewModel = new UCShipInfoViewModel();
            DataContext = viewModel;
            //bindingService = null;
        }

        public void SetShipInfo(ShipDraught calcDraught, ShipDraught realDraught)
        {
			if(calcDraught != null) 
			{
				viewModel.CalcAftPDraft = calcDraught.AftPDraft;
				viewModel.CalcAftSDraft = calcDraught.AftSDraft;
				viewModel.CalcMidPDraft = calcDraught.MidPDraft;
				viewModel.CalcMidSDraft = calcDraught.MidSDraft;
				viewModel.CalcFwdPDraft = calcDraught.FwdPDraft;
				viewModel.CalcFwdSDraft = calcDraught.FwdSDraft;
				viewModel.CalcHeel = calcDraught.Heel;
				viewModel.CalcTrim = calcDraught.Trim;

				viewModel.CalcDisp = calcDraught.Disp;
				viewModel.CalcCargoW = calcDraught.CargoW;
				viewModel.CalcBallastW = calcDraught.BallastW;
				viewModel.CalcLcg = calcDraught.Lcg;
				viewModel.CalcKmt = calcDraught.Kmt;
				viewModel.CalcGm = calcDraught.Gm;
			}

			if (realDraught != null) 
			{
				viewModel.RealAftPDraft = realDraught.AftPDraft;
				viewModel.RealAftSDraft = realDraught.AftSDraft;
				viewModel.RealMidPDraft = realDraught.MidPDraft;
				viewModel.RealMidSDraft = realDraught.MidSDraft;
				viewModel.RealFwdPDraft = realDraught.FwdPDraft;
				viewModel.RealFwdSDraft = realDraught.FwdSDraft;
				viewModel.RealHeel = realDraught.Heel;
				viewModel.RealTrim = realDraught.Trim;
			}
		}

		public ShipDraught GetRealShipInfo()
		{
			ShipDraught shipDraught = new ShipDraught();
			shipDraught.AftPDraft = viewModel.RealAftPDraft;
			shipDraught.AftSDraft = viewModel.RealAftSDraft;
			shipDraught.MidPDraft = viewModel.RealMidPDraft;
			shipDraught.MidSDraft = viewModel.RealMidSDraft;
			shipDraught.FwdPDraft = viewModel.RealFwdPDraft;
			shipDraught.FwdSDraft = viewModel.RealFwdSDraft;
			return shipDraught;
		}
	}
}
